class Solution:
    def addDigits(self, num: int) -> int:
        if num < 10:
            return num
        numSum = 0
        while num:
            numSum += num % 10
            num = num // 10
        return self.addDigits(numSum)


if __name__ == '__main__':
    so = Solution()
    m = 38
    r = so.addDigits(m)
    print(r)
